home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 424_02 / ED-157 / buffer_empty.c < prev    next >
C/C++ Source or Header  |  1993-09-10  |  2KB  |  49 lines

  1. /*
  2.  * Copyright (C) 1992 by Rush Record (rhr@clio.rice.edu)
  3.  * 
  4.  * This file is part of ED.
  5.  * 
  6.  * ED is free software; you can redistribute it and/or modify it under the terms
  7.  * of the GNU General Public License as published by the Free Software Foundation.
  8.  * 
  9.  * ED is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  10.  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  11.  * PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  12.  * 
  13.  * You should have received a copy of the GNU General Public License along with ED
  14.  * (see the file COPYING).  If not, write to the Free Software Foundation, 675
  15.  * Mass Ave, Cambridge, MA 02139, USA.
  16.  */
  17. #include "opsys.h"
  18.  
  19. #include <stdio.h> 
  20. #include <stdlib.h> 
  21.  
  22. #include "rec.h"
  23. #include "buffer.h"
  24.  
  25. /******************************************************************************\
  26. |Routine: buffer_empty
  27. |Callby: carriage_ret command copier include_file inquire killer load_buffer openline output_file sort_recs str_to_buf word_fill
  28. |Purpose: Removes all records from a buffer and frees them.
  29. |Arguments:
  30. |    buffer is the buffer to be emptied.
  31. \******************************************************************************/
  32. void buffer_empty(buffer)
  33. buf_ptr buffer;
  34. {
  35.     register rec_ptr e,next,b;
  36.  
  37.     for(b = buffer->first,e = (rec_ptr)&buffer->first;b != e;)
  38.     {
  39.         next = b->next;
  40.         remq(b);
  41.         if(b->data && (b->recflags & 1))
  42.             ifree(b->data);
  43.         ifree(b);
  44.         b = next;
  45.     }
  46.     buffer->nrecs = 0;
  47. }
  48.  
  49.